import QtQuick 2.0
import QtQuick.Controls 2.0

import Triangle 1.0

Rectangle {
    width: 800
    height: 600
    color: Qt.rgba(0.2, 0.3, 0.3, 1.0)
    Triangle {
        width: 800
        height: 600
        anchors.centerIn : parent
        NumberAnimation on angle {
            from: 0
            to: 360
            duration: 10000
            running: true
            loops: Animation.Infinite
        }
    }

    Item {
        id: fpsItem
        property real fps: 0.0
        property int count: 0
        anchors {
            right: parent.right
            top: parent.top
            rightMargin: 60
            topMargin: 20
        }
        Item {
            NumberAnimation on rotation {
                duration: 1000
                from: 0
                to: 360
                loops: -1
            }
            onRotationChanged: fpsItem.count++
        }
        Text {
            anchors.centerIn: parent
            text: "FPS " + fpsItem.fps.toFixed(1)
            color: "red"
            font.pointSize: 14
        }
        Timer {
            interval: 1000
            onTriggered: {
                fpsItem.fps = fpsItem.count;
                fpsItem.count = 0;
            }
            repeat: true
            running: true
        }
    }
}
